Refactor BitwiseXOR operator using ScalarUDF framework#20086
Refactor BitwiseXOR operator using ScalarUDF framework#20086Acfboy wants to merge 1 commit intoapache:mainfrom
Conversation
|
Hi @2010YOUY01, I've submitted the pilot pr for bitwise_xor as we discussed. Looking forward to your feedback! The implementation logic for bitwise_or and bitwise_and is very similar to bitwise_xor. If this approach is acceptable, I plan to refactor those operators using macros in a follow-up step. |
|
At what phase of planning do we do this replacement? I have a concern that we have optimizer rules based around binary exprs that are |
|
Hi @Jefffrey, thanks for the feedback! My apologies, I didn't consider this thoroughly enough. I realize now that making this change directly (during the initial conversion from statement to LogicalPlan) would break the optimizer. For instance, I haven't even migrated the logic from simplify_expr to the UDF's simplify method yet. I will convert this pr to a draft for now and carefully study the impact of this change on existing optimization rules. |
|
Thank you for this POC; it helps clarify the issue. I see two benefits to unifying operators and UDFs:
This PR’s approach is to replace operator inside As a middle ground, I have another idea (this gives up #[derive(Debug, Clone, Eq)]
pub struct BinaryExpr {
left: Arc<dyn PhysicalExpr>,
op: Operator,
right: Arc<dyn PhysicalExpr>,
/// Specifies whether an error is returned on overflow or not
fail_on_overflow: bool,
inner: Arc<dyn ScalarUDF>,
}Here, This way, operators and UDFs could share a consistent interface and reuse utilities like signature checking and user-friendly error messages. I think this approach is feasible, though I may be underestimating the difficulty since I haven’t worked extensively in these modules; I believe @Jefffrey has a deeper understanding here. |
Which issue does this PR close?
Rationale for this change
This PR is a pilot implementation of #20018. By refactoring operator into the ScalarUDF framework, we aim to:
What changes are included in this PR?
Refactor BitwiseXOR operator handling using ScalarUDF framework
Are these changes tested?
Yes.
Are there any user-facing changes?
No.